USE [influenza]
GO

/****** Object:  StoredProcedure [dbo].[SP_datPacientes]    Script Date: 02/17/2010 17:44:19 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



ALTER PROCEDURE [dbo].[SP_datPacientes]
@param varchar(10)
as
Begin
declare @qry VARCHAR(8000)

SET @qry='SELECT cNombre,cPaterno,cMaterno,curp,nSexo,nDias,nMeses,nAnio,
CONVERT(varchar(10),d.fSintoma_inicial,103) as fSintoma_inicial,
CONVERT(varchar(10),d.fMuestra,103)as fMuestra, upper(b.cNentidad) as entidad, 
upper(c.cNmunicipio) as municipio, 
	a.nEntidad as lent
	FROM dat_generales a
	left join dat_laboratorio d on (a.id_principal=d.id_generales)
	left join catalogos.dbo.entidades_inegi b on (a.nEntidad = b.id_entidad) 
    left join catalogos.dbo.municipios_inegi c on (a.nMunicipio = c.id_principal)
	WHERE d.id_registro='+@param
exec (@qry)

End
GO

